﻿<link href="@Url.Content("~/content/activitie_detail.css")" rel="stylesheet" type="text/css"/>
<link href="@Url.Content("~/content/table_btn.css")" rel="stylesheet" type="text/css"/>

<!--[if !IE]> -->
    <link rel="stylesheet" href="@Url.Content("~/plugin/accordion/demo.css")">
    <script>document.documentElement.className = "js";</script>
    <script src="@Url.Content("~/plugin/accordion/json2.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_storage.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_cookie_storage.js")"></script>
<!-- <![endif]-->

<!--[if gte IE 8]>
    <link rel="stylesheet" href="@Url.Content("~/plugin/accordion/demo.css")">
    <script>document.documentElement.className = "js";</script>
    <script src="@Url.Content("~/plugin/accordion/json2.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_storage.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_cookie_storage.js")"></script>
<![endif]-->

<!--[if lt IE 8]>
    <link href="@Url.Content("~/content/activitie_create.css")" rel="stylesheet" type="text/css"/>
<![endif]-->

<noscript>
    <link href="@Url.Content("~/content/activitie_create.css")" rel="stylesheet" type="text/css"/>
    <link href="@Url.Content("~/content/activitie_noscript.css")" rel="stylesheet" type="text/css"/>
</noscript>

@model PessModel.Archive

@{
    ViewBag.Title = "Proposal Details";
}
 
<h2>Proposal Details</h2>
@*<div>@Html.ActionLink("编辑申报表", "Edit", "Archive", new {id=Model.ID },null)</div>*@
    <div>        
    @*@if(Roles.IsUserInRole("Admin"))
            {
                @Html.ActionLink("Re-score", "EditScores2", "Score", new { archiveID = Model.ID  }, null) 
            }*@
    </div>
<div id="operate">
    @if ((bool)ViewBag.IsArchiveModificationAllowed)
    {
        if (Roles.IsUserInRole("Admin"))
        {
            @Html.ActionLink("Edit", "Edit", "Archive", new { id = Model.ID }, null)             
        }
        @*else if( Roles.IsUserInRole("Author"))
        {
            @Html.ActionLink("Edit", "EditProposal", new { id = Model.ID })
        }*@
    }
    @*&#8195; @Html.ActionLink("Review Feedback", "Feedback", "Archive", new { serialNumber = Model.SerialNumber }, null)*@ 
    @*&#8195; @Html.ActionLink("历史档案", "PreviousArchives", "Archive", new { archiveID = Model.ID }, null)*@
    @*&#8195;@Html.ActionLink("Back", "Index", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)*@
</div>
<div id="custom-show-hide-example" style="margin-top:50px;">

    @if (Model.Attachments.Count > 0)
    {
        <h3 class="open"> Paper</h3>
        <div>
            <div id="showFile" class="displayValue">
                @{
        var grid = new WebGrid(Model.Attachments, defaultSort: "Title");
                }
                @grid.GetHtml(columns: from c in grid.Columns(
                 grid.Column("Title", header: " File Name "), //format: @<text>@Html.ActionLink((string)item.Title, "Download", "Archive", new { archiveID = Model.ID, title = (string)item.Title }, null)</text>),
                 grid.Column("FileSize", header: " Size（KB） "),
                 grid.Column("TimeStamp", header: " Date Modified "),
                 grid.Column("Review", header: "", format: @<text>@Html.ActionLink("Download", "Download", "Archive", new { archiveID = Model.ID, title = (string)item.Title }, null)</text>),
                 grid.Column("Operation", header: "Operation", format: @<text>@Html.ActionLink("Delete", "DeleteAttachment", "Archive", new { archiveID = Model.ID, title = (string)item.Title }, null)</text>)
             )
                                       where !c.ColumnName.Contains("Operation") || (Roles.IsUserInRole("Admin") || Roles.IsUserInRole("CountyAdmin"))
                                       select c
                                                  )
            </div>
            <br />
        </div>
    }

<h3 class="close">Proposal</h3>
 <div>
@Html.Partial("_ArchiveDetailsFull", Model)
</div>

  

<!--Review Proposal Begin-->
<!--Other roles-->
    @if (User.IsInRole("Admin") || User.IsInRole("Chair") || User.IsInRole("Editor"))
{
    <h3 class="close"> Proposal Review Results</h3>
    <div>
        <fieldset class="show">
            <legend></legend>

            @if (Model.ExpertComments.Count > 0)//list all reviewers' results
            {
                int x = 1;
                foreach (var rf in Model.ExpertComments)
                {
                   <div class="ReviewBox">
                <div class="ReviewHeader" style="margin-top:-15px;">Review #@x: @rf.ExpertJudge.RealName
                    @if (rf.AcceptanceStatus == 1)
                    {
                        <img src="@Url.Content("~/images/green20.png")" alt="Accepted" style="vertical-align:text-top;margin-left:30px;" title="Accepted" />;
                    }
                    else if (rf.AcceptanceStatus == 0)
                    {
                        <img src="@Url.Content("~/images/red20.png")" alt="Rejected" style="vertical-align:text-top;margin-left:30px;" title="Rejected" />;
                    }
                </div>
                <div class="ReviewBody" style="">
                    @foreach (var s in Model.Scores.Where(s => s.ExpertJudgeSerialNumber == rf.ExpertSerialNumber))
                    {
                        <div class="display-label-rules">
                             @s.Rule.Name
                        </div>
                        <div class="display-field-rules">
                            @s.Value
                        </div>
                    }
                    <div class="display-label-rules">
                        Total
                    </div>
                    <div class="display-field-rules">
                        @((Model.Scores.Where(s => s.ExpertJudgeSerialNumber == rf.ExpertSerialNumber).Sum(s => s.Value) / 60).Value.ToString("P1"))
                    </div>
                    <div class="display-label-rules" >
                        Comment to the author
                    </div>
                    <div class="display-field-rules">
                        @rf.Comment
                    </div>
                    <div class="display-label-rules">
                        Comment to the review board chair
                    </div>
                    <div class="display-field-rules">
                        @rf.CommentsForChair
                    </div>
                    <div class="display-label-rules" >
                        Recommendation
                    </div>
                    <div class="display-field-rules">
                        @((PessModel.AcceptanceStatus)rf.AcceptanceStatus)
                    </div>
                </div>
            </div>
                    x++;
                }
            }
            else
            {
                <h3>There is no review record available for this proposal!</h3>
            }
        </fieldset>
    </div>
}
    else if (User.IsInRole("ExpertJudge")) { 
    <h3 class="close">Review Proposal</h3>
    <div>
        <fieldset class="show">
            <legend></legend>
            @{decimal totalscore = 0;}
            @foreach (var rule in Model.Subject.Rules)
            {
                var ascores = Model.Scores.Where(s => s.RuleID == rule.ID && s.ExpertJudgeSerialNumber == Membership.GetUser().UserName);
                int svalue = 0;
                if (ascores.Count() == 1)
                {
                    svalue = Convert.ToInt32(ascores.FirstOrDefault().Value);
                    totalscore += svalue;
                }

                <div class="display-label-rules">@rule.Name</div>
                <div class="display-field-rules">
                    @svalue
                </div>
            }

            <div class="display-label-rules">Total</div>
            <div class="display-field-rules">
                @((totalscore / 60).ToString("P1"))
            </div>


            @{var pessEC = Model.ExpertComments.Where(ecc => ecc.ArchiveID == Model.ID && ecc.ExpertSerialNumber == Membership.GetUser().UserName).FirstOrDefault(); }
            @if (pessEC == null)
            {

            }
            else
            {
                <div class="display-label-rules">Comment to the author:</div>
                <div class="display-field-rules">
                    @pessEC.Comment
                </div>
                <div class="display-label-rules">Comment to the review board chair:</div>
                <div class="display-field-rules">
                    @pessEC.CommentsForChair
                </div>
                <div class="display-label-rules">Recommendation</div>
                <div class="display-field-rules">
                    @((PessModel.AcceptanceStatus)pessEC.AcceptanceStatus)
                </div>
            }



        </fieldset>

        </div>
    }
        <!--Review Proposal End-->
        <!--Review Paper Begin-->
        <!--Reviewer-->
        @if (Roles.IsUserInRole(Membership.GetUser().UserName, "ExpertJudge") && Model.Status == 4 && Model.PaperStatus >= 2)
        {

            <h3 class="close">Review Paper</h3>
            <div>

                @if (Model.PaperStatus == 2)
                {
                    <fieldset class="edit">
                        <legend></legend>
                        @using (Html.BeginForm("SavePaperReview", "Score", FormMethod.Post, new { id = "frmReviewer", name = "frmReviewer" }))
                        {
                            int x = 0;
                            foreach (var rule in Model.Subject.Activity.PaperRules)
                            {
                                var ascores = Model.PaperScores.Where(s => s.RuleID == rule.ID && s.ExpertJudgeSerialNumber == Membership.GetUser().UserName);
                                int svalue = 0;
                                if (ascores.Count() == 1)
                                {
                                    svalue = Convert.ToInt32(ascores.FirstOrDefault().Value);
                                }

                                <div class="editor-label editor-label-rules">@rule.Name</div>
    <div class="editor-field editor-field-rules">
        @for (int i = 1; i <= rule.Value; i++)
        {
            //<input type="radio" name="@rule.ID" value="@i" style="margin-left:10px" /> @i
            if (svalue == i)
            {
                <input type="radio" name="paperscores[@x].ScoreValue" value="@i" style="margin-left:10px" checked="checked" required /> @i
            }
            else
            {
                <input type="radio" name="paperscores[@x].ScoreValue" value="@i" style="margin-left:10px" required /> @i
            }
            @Html.Hidden("paperscores[" + x + "].RuleID", rule.ID)
        }
        <span class="field-validation-valid" data-valmsg-for="paperscores[@x].ScoreValue" data-valmsg-replace="true"></span>
    </div>
        x++;
                            }

                            var pessPEC = Model.PaperComments.Where(ecc => ecc.ArchiveID == Model.ID && ecc.ExpertSerialNumber == Membership.GetUser().UserName).FirstOrDefault();
                            if (pessPEC == null)
                            {
                                
                                <div class="editor-label  editor-label-rules">Recommendation:</div>
                                <div class="editor-field editor-field-rules">
                                    <input type="radio" value="1" name="accepted" required /> Accept
                                    <input type="radio" value="0" name="accepted" /> Reject
                                    <input type="radio" value="2" name="accepted" /> Accept with revision
                                    <span class="field-validation-valid" data-valmsg-for="accepted" data-valmsg-replace="true"></span>
                                </div>
                            <div class="editor-label  editor-label-rules" style="height:90px">Comments to the author:</div>
                                <div class="editor-field editor-field-rules">
                                    <textarea id="Comment" name="Comment" style="width:600px;" required></textarea><br />
                                    <span class="field-validation-valid" data-valmsg-for="Comment" data-valmsg-replace="true"></span>
                                </div>
                            <div class="editor-label  editor-label-rules" style="height:90px">Comments to the review board chair: </div>
                            <div class="editor-field editor-field-rules">
                                <textarea id="CommentsForChair" name="CommentsForChair" style="width:600px;" required></textarea><br />
                                <span class="field-validation-valid" data-valmsg-for="CommentsForChair" data-valmsg-replace="true"></span>
                                </div>
                            }
                            else
                            {
                                
                                <div class="editor-label editor-label-rules">Recommendation</div>

                                if (pessPEC.PaperStatus == 0)
                                {
                                    <div class="editor-field editor-field-rules">
                                        <input type="radio" value="1" name="accepted" required /> Accept
                                        <input type="radio" value="0" name="accepted" checked="checked" /> Reject
                                        <input type="radio" value="2" name="accepted" /> Accept with revision
                                        <span class="field-validation-valid" data-valmsg-for="accepted" data-valmsg-replace="true"></span>
                                    </div>
                                }
                                else if (pessPEC.PaperStatus == 1)
                                {
                                    <div class="editor-field editor-field-rules">
                                        <input type="radio" value="1" name="accepted" checked="checked" required /> Accept
                                        <input type="radio" value="0" name="accepted" /> Reject
                                        <input type="radio" value="2" name="accepted" /> Accept with revision
                                        <span class="field-validation-valid" data-valmsg-for="accepted" data-valmsg-replace="true"></span>
                                    </div>
                                }
                                else if (pessPEC.PaperStatus == 2)
                                {
                                    <div class="editor-field editor-field-rules">
                                        <input type="radio" value="1" name="accepted" required /> Accept
                                        <input type="radio" value="0" name="accepted" /> Reject
                                        <input type="radio" value="2" name="accepted" checked="checked" /> Accept with revision
                                        <span class="field-validation-valid" data-valmsg-for="accepted" data-valmsg-replace="true"></span>
                                    </div>
                                }
                                <div class="editor-label  editor-label-rules" style="height:90px">Comment to the author:</div>
                                <div class="editor-field editor-field-rules">
                                    <textarea id="Comment" name="Comment" style="width:600px;" required>@pessPEC.Comment</textarea><br />
                                    <span class="field-validation-valid" data-valmsg-for="Comment" data-valmsg-replace="true"></span>
                                </div>
                           <div class="editor-label  editor-label-rules" style="height:90px">Comments to the review board chair: </div>
                            <div class="editor-field editor-field-rules">
                                <textarea id="CommentsForChair" name="CommentsForChair" style="width:600px;" required>@pessPEC.CommentsForChair</textarea><br />
                                <span class="field-validation-valid" data-valmsg-for="CommentsForChair" data-valmsg-replace="true"></span>
                                </div>
                            }
                            <input type="hidden" name="archiveid" value="@Model.ID" />
                            <div class="editor-btn editor-btn-rules">
                                <input type="submit" value="Save" />
                                @Html.ActionLink("Cancel", "PaperIndex", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
                            </div>

                        }
                    </fieldset>
                }
                else if (Model.PaperStatus > 2)
                {
                    <fieldset class="show">
                        <legend></legend>
                        @{decimal totalscore = 0;}
                        @foreach (var rule in Model.Subject.Activity.PaperRules)
                        {
                            var ascores = Model.PaperScores.Where(s => s.RuleID == rule.ID && s.ExpertJudgeSerialNumber == Membership.GetUser().UserName);
                            int svalue = 0;
                            if (ascores.Count() == 1)
                            {
                                svalue = Convert.ToInt32(ascores.FirstOrDefault().Value);
                                totalscore += svalue;
                            }
                            <div class="display-label-rules">@rule.Name</div>
                            <div class="display-field-rules">
                                @svalue
                            </div>
                        }

                        <div class="display-label-rules">Total</div>
                        <div class="display-field-rules">
                            @((totalscore / 90).ToString("P1"))
                        </div>

                        @{var pessPEC = Model.PaperComments.Where(ecc => ecc.ArchiveID == Model.ID && ecc.ExpertSerialNumber == Membership.GetUser().UserName).FirstOrDefault();}
                        @if (pessPEC == null)
                        {

                        }
                        else
                        {
                            <div class="display-label-rules">Comments to the author:</div>
                            <div class="display-field-rules">
                                @pessPEC.Comment
                            </div>
                            <div class="display-label-rules">Comments to the review board chair:</div>
                            <div class="display-field-rules">
                                @pessPEC.Comment
                            </div>
                            <div class="display-label-rules">Accept/Reject</div>
                            <div class="display-field-rules">
                                @pessPEC.PaperStatus
                            </div>
                        }

                        <div class="operate_bottom">
                            @Html.ActionLink("Back", "PaperIndex", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
                        </div>
                    </fieldset>
                }

            </div>
            @*//jijun
                    <div>
                    <div id="scores" class="displayConScroe">
                        @Html.Action("ArchiveExpertScores", "Score", new { archiveID = Model.ID })
                    </div>
                    <br />
                    @if (ViewBag.IsScoreInputAllowed)
                    {
                        <div id="scoreButtons" style="display:none">
                            <span id="editScoresBtn" class="asBtn" >Score</span>
                            <span id="deleteScoresBtn" class="asBtn" >Delete</span>
                            <span id="saveScoresBtn" class="asBtn">Save</span>
                            <span id="cancelBtn" class="asBtn">Cancel</span>
                        </div>
                        @Html.ActionLink("Score", "EditScores2", "Score", new { archiveID = Model.ID }, new { id = "editScoresBtn2" })
                    }

                </div>*@
        }
        <!--Review Paper End-->
        <!--All of below-->
        @if (User.IsInRole("Admin") || User.IsInRole("Chair") || User.IsInRole("Editor"))
        {
            <h3 class="open"> Paper Review Results</h3>
            <div>
                <fieldset class="show">
                    <legend></legend>

                    @if (Model.PaperComments.Count > 0)//list all reviewers' results
                    {
                        int x = 1;
                        foreach (var rf in Model.PaperComments)
                        {
                            <div class="ReviewBox">
                                <div class="ReviewHeader" style="margin-top:-15px;">
                                    Review #@x: @rf.ExpertJudge.RealName
                                    @if (rf.PaperStatus == 1)
                                    {
                                        <img src="@Url.Content("~/images/green20.png")" alt="Accepted" style="vertical-align:text-top;margin-left:30px;" title="Accepted" />;
                                    }
                                    else if (rf.PaperStatus == 2)
                                    {
                                        <img src="@Url.Content("~/images/yellow20.png")" alt="Rejected" style="vertical-align:text-top;margin-left:30px;" title="Revise" />;
                                    }
                                    else if (rf.PaperStatus == 0)
                                    {
                                        <img src="@Url.Content("~/images/red20.png")" alt="Rejected" style="vertical-align:text-top;margin-left:30px;" title="Rejected" />;
                                    }
                                </div>
                                <div class="ReviewBody" style="">
                                    @foreach (var s in Model.PaperScores.Where(s => s.ExpertJudgeSerialNumber == rf.ExpertSerialNumber))
                                    {
                                        <div class="display-label-rules">
                                            @s.PaperRule.Name
                                        </div>
                                        <div class="display-field-rules">
                                            @s.Value
                                        </div>
                                    }
                                    <div class="display-label-rules">
                                        Total
                                    </div>
                                    <div class="display-field-rules">
                                        @((Model.PaperScores.Where(s => s.ExpertJudgeSerialNumber == rf.ExpertSerialNumber).Sum(s => s.Value) / 90).Value.ToString("P1"))
                                    </div>
                                    <div class="display-label-rules">
                                        Comments to the author
                                    </div>
                                    <div class="display-field-rules">
                                        @rf.Comment
                                    </div>
                                    <div class="display-label-rules">
                                        Comments to the review board chair/editor
                                    </div>
                                    <div class="display-field-rules">
                                        @rf.CommentsForChair
                                    </div>
                                    <div class="display-label-rules">
                                        Status
                                    </div>
                                    <div class="display-field-rules">
                                        @((PessModel.PaperAcceptanceStatus)rf.PaperStatus)
                                    </div>
                                </div>
                            </div>
                                    x++;
                        }
                    }
                    else
                    {
                        <h3>There is no review record available for this proposal!</h3>
                    }
                </fieldset>
            </div>
        }

        <!--admin-->
        @if (User.IsInRole("Admin"))
        {
            //nothing now
        }
        <!--Chair-->
        @if (User.IsInRole("Chair"))
        {
            //=2, display feedback editor for Chair
            <h3 class="open">Review Paper</h3>
            <div>

                @if (Model.PaperStatus == 2)
                {
                    using (Html.BeginForm("SubmitChairReviewFeedback", "Archive", FormMethod.Post, new { id = "frmChair", name = "frmChair" }))
                    {
                        <fieldset class="edit">
                            <legend></legend>
                            <div class="editor-label" style="height:90px">Comment:</div>
                            <div class="editor-field">
                                <textarea id="ReviewFeedback" name="ReviewFeedback" style="width:700px;" required>@Model.ReviewFeedback</textarea><br />
                                <span class="field-validation-valid" data-valmsg-for="ReviewFeedback" data-valmsg-replace="true"></span>
                            </div>
                            <div class="editor-label">Suggestion:</div>
                            @if(Model.ChairPaperStatus==0)
                            { 
                            <div class="editor-field">
                                <input type="radio" value="0" name="accept" required checked="checked"/> Reject
                                <input type="radio" value="2" name="accept" /> Accept with revision
                                <input type="radio" value="1" name="accept" /> Accept
                                <span class="field-validation-valid" data-valmsg-for="accept" data-valmsg-replace="true"></span>
                            </div>
                            }
                            else if(Model.ChairPaperStatus==1)
                            {
                                <div class="editor-field">
                                <input type="radio" value="0" name="accept" required /> Reject
                                <input type="radio" value="2" name="accept" /> Accept with revision
                                    <input type="radio" value="1" name="accept" checked="checked" /> Accept
                                    <span class="field-validation-valid" data-valmsg-for="accept" data-valmsg-replace="true"></span>
                            </div>
                                
                            }
                            else if (Model.ChairPaperStatus == 2)
                            {
                            <div class="editor-field">
                                <input type="radio" value="0" name="accept" required /> Reject
                                <input type="radio" value="2" name="accept" checked="checked" /> Accept with revision
                                <input type="radio" value="1" name="accept" /> Accept
                                <span class="field-validation-valid" data-valmsg-for="accept" data-valmsg-replace="true"></span>
                            </div>
                            }
                            else
                            {
                            <div class="editor-field">
                                <input type="radio" value="0" name="accept" required /> Reject
                                <input type="radio" value="2" name="accept" /> Accept with revision
                                <input type="radio" value="1" name="accept" /> Accept
                                <span class="field-validation-valid" data-valmsg-for="accept" data-valmsg-replace="true"></span>
                            </div>
                            }
                            <input type="hidden" name="archiveid" value="@Model.ID" />
                            <div class="editor-btn">
                                <input type="submit" value="Save" id="btnSave"/>
                                <input type="submit" value="Submit" id="btnSubmit"/>
                                @Html.ActionLink("Cancel", "PaperIndex", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
                            </div>
                        </fieldset>
                    }
                }
                else
                {
                    <fieldset class="show">
                        <legend></legend>
                        <div class="ReviewBox">
                            <div class="ReviewHeader" style="margin-top:-15px;">
                                Chair
                                @if (Model.ChairPaperStatus == 1)
                                {
                                    <img src="@Url.Content("~/images/green20.png")" alt="Accepted" style="vertical-align:text-top;margin-left:30px;" title="Accepted" />;
                                }
                                else if (Model.ChairPaperStatus == 2)
                                {
                                    <img src="@Url.Content("~/images/yellow20.png")" alt="Revise" style="vertical-align:text-top;margin-left:30px;" title="Revise" />;
                                }
                                else if (Model.ChairPaperStatus == 0)
                                {
                                    <img src="@Url.Content("~/images/red20.png")" alt="Rejected" style="vertical-align:text-top;margin-left:30px;" title="Rejected" />;
                                }
                            </div>
                            <div class="ReviewBody" style="">
                                <div class="display-label">
                                    Review Feedback
                                </div>
                                <div class="display-field">
                                    @Model.ReviewFeedback
                                </div>
                                <div class="display-label">
                                    Chair's Suggestion:
                                </div>
                                <div class="display-field">
                                    @Model.ChairPaperStatusName
                                </div>
                            </div>
                        </div>
                    </fieldset>
                    
                    <div class="operate_bottom">
                            @Html.ActionLink("Back", "PaperIndex", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
                     </div>
                }

            </div>
        }
        <!--Editor-->
        @if (User.IsInRole("Editor"))
        {
            //=2,3,4, display feedback editor for Editor
            //>4, diaplay feedback label for Editor
            <h3 class="open">Chair's Review Result</h3>
            <div>

                <fieldset class="show">
                    <legend></legend>
                    <div class="ReviewBox">
                        <div class="ReviewHeader" style="margin-top:-15px;">
                            Chair
                            @if (Model.ChairPaperStatus == 1)
                            {
                                <img src="@Url.Content("~/images/green20.png")" alt="Accepted" style="vertical-align:text-top;margin-left:30px;" title="Accepted" />;
                            }
                            else if (Model.ChairPaperStatus == 2)
                            {
                                <img src="@Url.Content("~/images/yellow20.png")" alt="Revise" style="vertical-align:text-top;margin-left:30px;" title="Revise" />;
                            }
                            else if (Model.ChairPaperStatus == 0)
                            {
                                <img src="@Url.Content("~/images/red20.png")" alt="Rejected" style="vertical-align:text-top;margin-left:30px;" title="Rejected" />;
                            }
                        </div>
                        <div class="ReviewBody" style="">
                            <div class="display-label">
                                Review Feedback
                            </div>
                            <div class="display-field">
                                @Model.ReviewFeedback
                            </div>
                            <div class="display-label">
                                Chair's Suggestion:
                            </div>
                            <div class="display-field">
                                @Model.ChairPaperStatusName
                            </div>
                        </div>
                    </div>
                </fieldset>
            </div>

            <h3 class="open">Review Paper</h3>
            <div>


                @*@if (Model.PaperStatus >= 2 && Model.PaperStatus <= 5)
                {*@
                    <fieldset class="edit">
                        <legend></legend>
                        @using (Html.BeginForm("SaveEditorReviewFeedback", "Archive", FormMethod.Post, new { id = "frmEditor", name = "frmEditor" }))
                        {
                            <div class="editor-label" style="height:400px">Comment:</div>
                            <div class="editor-field">
                                <textarea id="ReviewFeedback" name="ReviewFeedback" style="width:700px; height:400px" required>@Model.EditorPaperReviewFeedback</textarea><br />
                                <span class="field-validation-valid" data-valmsg-for="ReviewFeedback" data-valmsg-replace="true"></span>
                            </div>
                            <div class="editor-label">Final Decision:</div>
                            <div class="editor-field">
                                @if(Model.PaperStatus==5)
                                { 
                                    <input type="radio" value="5" name="accept" required checked="checked" /> <label>Reject</label> 
                                }
                                else
                                { 
                                    <input type="radio" value="5" name="accept" required /> <label>Reject</label> 
                                 }
                                <input type="radio" value="7" name="accept" /> Accept with revision
                                <input type="radio" value="6" name="accept" /> Accept
                                <span class="field-validation-valid" data-valmsg-for="accept" data-valmsg-replace="true"></span>
                            </div>
                            <input type="hidden" name="archiveid" value="@Model.ID" />
                            <div class="editor-btn">
                                <input type="submit" value="Save" />
                                @Html.ActionLink("Cancel", "PaperIndex", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
                            </div>}

                    </fieldset>

                @*}*@
                @*else if (Model.PaperStatus > 5)//Disable paper status modification
                {
                    <fieldset class="show">
                        <legend></legend>
                        <div class="ReviewBox">
                            <div class="ReviewHeader" style="margin-top:-15px;">
                                Editor
                                @if (Model.PaperStatus == 6)
                                {
                                    <img src="@Url.Content("~/images/green20.png")" alt="Accepted" style="vertical-align:text-top;margin-left:30px;" title="Accepted" />;
                                }
                                else if (Model.PaperStatus == 7)
                                {
                                    <img src="@Url.Content("~/images/yellow20.png")" alt="Revise" style="vertical-align:text-top;margin-left:30px;" title="Revise" />;
                                }
                                else if (Model.PaperStatus == 5)
                                {
                                    <img src="@Url.Content("~/images/red20.png")" alt="Rejected" style="vertical-align:text-top;margin-left:30px;" title="Rejected" />;
                                }
                            </div>
                            <div class="ReviewBody" style="">
                                <div class="display-label">
                                    Review Feedback
                                </div>
                                <div class="display-field">
                                    @Model.EditorPaperReviewFeedback
                                </div>
                                <div class="display-label">
                                    Paper Status:
                                </div>
                                <div class="display-field">
                                    @Model.PaperStatusName
                                </div>
                            </div>
                        </div>

                    </fieldset>
                    <div class="operate_bottom">
                            @Html.ActionLink("Back", "PaperIndex", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
                        </div>
                }*@


            </div>
        }

    </div>

<div id="dialog-message" title="Message">
    <p>
        <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;">Message</span>
        <span id="msg_in_dialog"></span>
    </p>
</div>


<!--[if !IE]> -->
      <script>
          $(document).ready(function () {

              new jQueryCollapse($("#custom-show-hide-example"), {
                  open: function () {
                      this.slideDown(150);
                  },
                  close: function () {
                      this.slideUp(150);
                  }
              });


          });
      </script>
<!-- <![endif]-->

<!--[if gte IE 8]>
      <script>
          new jQueryCollapse($("#custom-show-hide-example"), {
              open: function() {
                  this.slideDown(150);
              },
              close: function() {
                  this.slideUp(150);
              }
          });
      </script>
<![endif]-->

<script>
    $(document).ready(function () {
        var submiturl = "";
        var usedefaulturl = true;

        $("#btnSubmit").click(function () {
            usedefaulturl = true;
        });
        $("#btnSave").click(function () {
            submiturl = '@(Url.Content("~/Archive/SaveChairReviewFeedback"))';
                  usedefaulturl = false;
              });

        $("#dialog-message").hide();

        $("form").validate({
            submitHandler: function (form) {
                // alert("submitted!");
                form.submit();
            },
            invalidHandler: function (event, validator) {
                //alert("no score");

            }
        });

        $("form").submit(function (event) {
            event.preventDefault();
            // Show the "busy" Gif:
            if ($(this).valid()) {
                $('#msg_in_dialog').html("Processing...<br/><br/><img src='@Url.Content("~/images/ajax-loader.gif")'>");
                      $("#dialog-message").dialog({
                          modal: true
                      });

                      var url = $(this).attr("action");
                      if (!usedefaulturl)
                          url = submiturl;
                      var formData = $(this).serialize();
                      $.ajax({
                          url: url,
                          type: "POST",
                          data: formData,
                          dataType: "json",
                          success: function (url) {
                              // Hide the "busy" gif:
                              $('#msg_in_dialog').html("Review submitted.");
                              if (!usedefaulturl) {
                                  $('#msg_in_dialog').html("Changes saved.<br/>However, you need to submit it to make it available for editor.");
                              }
                              $("#dialog-message").dialog({
                                  modal: true,
                                  buttons: {
                                      "Continue": function () {
                                          $("body").css("cursor", "progress");
                                          window.location.href = url;
                                          $(this).dialog("close");
                                      }
                                  }
                              });
                              // Do something useful with the data:
                          }
                      })
                  }
                  else {
                      //$('#msg_in_dialog').html("Please complete all the fields.");
                      //$("#dialog-message").dialog({
                      //    modal: true,
                      //    buttons: {
                      //        "Close": function () {
                      //            $(this).dialog("close");
                      //        }
                      //    }
                      //});
                  }
              });
    });
</script>
